import Cookies from 'js-cookie';
import configs from '@/config/index.js'
import useUserStorage from '@/stores/user.js'
import useCookieStore from '@/stores/cookieStorage.js'
import useLocalStore from '@/stores/local.js'

export function getToken() {


    return Cookies.get(configs.cookie_token_key)
}

export function setToken(token,days=7) {
    return Cookies.set(configs.cookie_token_key,token,{expires:days})
}


export function removeToken() {
    return Cookies.remove(configs.cookie_token_key)
}
// 便于nginx记录日志
export function setUserIdInCookie(userId){
    return Cookies.set('userId',userId)
}
export function logoutAction() {
    removeToken()
    useUserStorage().logout()
    useCookieStore().clear()
    useLocalStore().clear();
}
